package com.zc.cms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zc.cms.entity.CrmBanner;
import com.zc.cms.mapper.CrmBannerMapper;
import com.zc.cms.service.CrmBannerService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author cong
 * @since 2022-11-30
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {

	@Override
	@Cacheable(key = "'banner'", value = "bannerList")
	public List<CrmBanner> getAllBanner() {
		QueryWrapper<CrmBanner> queryWrapper = new QueryWrapper<>();
		queryWrapper.orderByDesc("id").last("limit 2");
		List<CrmBanner> bannerList = this.list(queryWrapper);
		return bannerList;
	}
}
